<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('岗位新增')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body>
<form id="user-form">
    <div class="ui-layout-center">
        <div class="container-div">
            <div class="row">
                <div class="col-sm-12 search-collapse">
                    <div class="select-list">
                        <ul>
                            <li>
                                岗位代码：<input type="text" name="jobCode" id="jobCode"/>
                            </li>
                            <li>
                                岗位名称：<input type="text" id="title" name="title"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>

                            </li>
                        </ul>
                    </div>
                </div>

                <div class="btn-group-sm" id="toolbar" role="group">
                    <a class="btn btn-success" onclick="$.operate.add()">
                        <i class="fa fa-plus"></i> 新增
                    </a>
                    <a class="btn btn-primary" onclick="$.operate.edit()">
                        <i class="fa fa-edit"></i> 修改
                    </a>
                    <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()">
                        <i class="fa fa-remove"></i> 删除
                    </a>
                    &nbsp;&nbsp;&nbsp;
                    <a class="btn btn-primary" onclick="threeProcedure('oSP_JobCheck')">确认检查</a>
                    <a class="btn btn-warning" onclick="threeProcedure('oSP_Jobcancel')">取消确认</a>
                    <a class="btn btn-success" onclick="threeProcedure('oSP_Jobstart')">执行新增</a>

                </div>

                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table" data-mobile-responsive="true"></table>
                </div>
            </div>
        </div>
    </div>
</form>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>


<script th:inline="javascript">

    var prefix = ctx + "job/admin";
    $(function () {
        var panehHidden = false;
        if ($(this).width() < 800) {
            panehHidden = true;
        }
        $('body').layout({initClosed: panehHidden, west__size: 350});
        findJobList();
    });

    function findJobList() {
        var columns = [];
        var checkbox = {checkbox: true};
        var id = {field: 'id', title: '序号'};
        var Jobcode = {field: 'Jobcode', title: '岗位代码'};
        var Title = {field: 'Title', title: '岗位名称'};
        var JobAbbr = {field: 'JobAbbr', title: '岗位简称'};
        var JobGradeTitle = {field: 'JobGradeTitle', title: '岗位级别'};
        var JobTypeTitle = {field: 'JobTypeTitle', title: '岗位类型'};
        var compTitle = {field: 'compTitle', title: '所属公司'};
        var DepIdTitle = {field: 'DepIdTitle', title: '所属部门'};
        var AdminIDTitle = {field: 'AdminIDTitle', title: '上级岗位'};
        var Jobnum = {field: 'Jobnum', title: '编制人数'};
        var jobText = {field: 'jobText', title: '岗位说明'};
        var effectdate = {field: 'effectdate', title: '成立日期'};
        var Remark = {field: 'Remark', title: '备注'};
        var RegByName = {field: 'RegByName', title: '登记人'};
        var RegDate = {field: 'RegDate', title: '登记时间'};
        var Initialized = {field: 'Initialized', title: '?确认'};
        var InitializedByName = {field: 'InitializedByName', title: '确认人'};
        var InitializedTime = {field: 'InitializedTime', title: '确认时间'};
        var submit = {field: 'submit', title: '?审核'};
        var submitBy = {field: 'submitBy', title: '审核人'};
        var submitTime = {field: 'submitTime', title: '审核时间'};


        columns.push(checkbox,id,Jobcode,Title,JobAbbr,JobGradeTitle,JobTypeTitle,compTitle,DepIdTitle);
        columns.push(AdminIDTitle,Jobnum,jobText,effectdate,Remark,RegByName,RegDate,Initialized,InitializedByName);
        columns.push(InitializedTime,submit,submitBy,submitTime);

        var options = {
            code: "id",
            uniqueId: "id",
            url: prefix + "/findJobList?type=1",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/editAdd/{id}",
            removeUrl: prefix + "/delete",
            detailUrl: prefix + "/detail/{id}",
            escape: true,
            showPageGo: true,
            rememberSelected: true,
            height: $(window).height() - 120,
            sortOrder: "desc",
            modalName: "部门",
            columns: columns
        };
        $.table.init(options);
    }

    function threeProcedure(procedure){
        var allId = "";
        var row = $("#bootstrap-table").bootstrapTable('getSelections');
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","
            }
        }
        $.ajax({
            url: prefix + "/procedure",
            data: {"allId": allId, "procedure": procedure},
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.data == null) {
                    $.modal.alertWarning(data.message);
                } else {
                    $.modal.alertSuccess(data.data);
                }

                $.table.refresh();
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                $.modal.alertWarning("错误,请联系管理员,错误信息:" + textStatus);
            }
        });
    }


    function getAllId(row) {
        var allId = "";
        for (var i = 0; i < row.length; i++) {
            if (i == row.length - 1) {
                allId += row[i].id
            } else {
                allId += row[i].id + ","

            }
        }
        return allId;
    }

</script>
</body>
</html>